<div class="main layui-clear">
	<div class="wrap">
	    <div class="content detail">
	      <h1>${topic.title!''}</h1>
	      <div class="fly-tip fly-detail-hint" data-id="{{rows.id}}">
	        <#if topic.cate>
	            <span class="fly-tip-cate">${topic.cate!''}</span>
	        </#if>
	        <#if topic.top>
	        	<span class="fly-tip-stick">置顶帖</span>
	        </#if>
	        <#if topic.essence>
	        	<span class="fly-tip-jing">精华帖</span>
	        </#if>
	        <#if !topic.finish>
	        	<span>未结帖</span>
	        <#else>
	        	<span style="background: orange;">已结帖</span>
	        </#if>
	        
	        <#if topic.accept>
	        <span class="fly-tip-jie">已采纳</span>
	        </#if>
	        
	        <div class="fly-list-hint"> 
	          <i class="iconfont" title="回答">&#xe60c;</i> ${topic.answers!0}
	          <i class="iconfont" title="人气">&#xe60b;</i> ${topic.views!0}
	        </div>
	      </div>
	      <div class="detail-about">
	        <a class="jie-user" href="/jsluntan/user/index/${topic.creater!''}.html">
	          <img src="/jsluntan/res/image/${topic.creater!''}.html" onerror="this.src='/jsluntan/images/user/default.png'" alt="">
	          <cite>
	          	<#if topicUser??>${topicUser.username!''}<#else>${topic.username!''}</#if>
	            <em>发布时间：${topic.createtime?string('yyyy-MM-dd HH:mm:ss')}</em>
	          </cite>
	        </a>
	        <div class="detail-hits" data-id="{{rows.id}}">
	          <span style="color:#FF7200">悬赏：${topic.price!0}</span>
	          <#if user.id == topic.creater && topic.finish == false>
	          <span class="jie-admin" type="edit"><a href="/jsluntan/topic/edit/${topic.id!''}.html">编辑此帖</a></span>
		      <span class="jie-admin" style="padding-left:0px;">
			       	<a href="javascript:void(0)" onclick="layer.confirm('结帖后不能取消，是否确认？' , {icon: 3, title:'操作提示'},function(){location.href = '/jsluntan/topic/finish/${topic.id!''}.html'} ,  function(index){layer.close(index);});return false;">
			       		<i class="layui-icon">&#xe618;</i>
			       		结帖
			       	</a>
			  </span>
	          </#if>
	        </div>
	      </div>
	      
	      <div class="detail-body photos" style="margin-bottom: 20px;">
	        
	        ${(topic.content!'')?no_esc}
	       <!--  <div  class="fly-ad" style="margin-top: 30px; height:90px; overflow: hidden;">
	        	广告位  
	        </div> -->
	      </div>
	      <#if topic.fileNames?? >
	      <div class="detail-body photos" style="margin-bottom: 20px;border-top:1px dashed #f2f2f5">
	      <h2 style="font-size:15px;">附件:</h2>
	      <#list topic.fileNames as fileName>
	      	<div><img src="../../images/jeesite/link.png"  style="width:20px;margin-right:10px;"/><a href="${topic.fileUrls[fileName_index]}" target='_blank'>${fileName}</a></div>
	      </#list>
	      </div>
	      </#if>
	      <a name="comment"></a>
	      <h2 class="page-title">回答<span>（<em id="jiedaCount">${topicCommentList.totalElements}</em>）</span></h2>
	
	      <ul class="jieda photos" id="jieda">
	      	<#if topicCommentList??>
	      	<#list topicCommentList.content as topicComment>
	        <li data-id="${topicComment.id!''}" class="jieda-daan">
	          <a name="${topicComment.id!''}"></a>
	          <div class="detail-about detail-about-reply">
	            <a class="jie-user" href="/jsluntan/user/index/${topicComment.creater!''}.html">
	              <img src="/jsluntan/res/image/${topicComment.creater!''}.html" onerror="this.src='/jsluntan/images/user/default.png'" alt="">
	              <cite>
	                <i><#if topicComment.user??>${topicComment.user.username!''}<#else>${topicComment.username!''}</#if></i>
	                <#if topicComment.creater == topic.creater><em>(楼主)</em></#if>
	                <#if topicComment.admin?? && topicComment.admin == true><em style="color:#5FB878">(管理员)</em></#if>
	              </cite>
	            </a>
	            <div class="detail-hits">
	              <span>回复于 ${topicComment.updatetime?string('yyyy-MM-dd HH:mm:ss')}</span>
	            </div>
	            <#if topicComment.optimal>
	            <i class="iconfont icon-caina" title="最佳答案"></i>
	            </#if>
	          </div>
	          <div class="detail-body jieda-body">
	            ${(topicComment.content!'')?no_esc}
	          </div>
	          <#if topicComment.fileNames?? >
	          <div class="detail-body jieda-body" style="border-top:1px dashed #f2f2f5">
    		  <h2 style="font-size:15px;">附件:</h2>
	          <#list topicComment.fileNames as fileName>
	      		<div><img src="../../jsluntan/images/jeesite/link.png"  style="width:20px;margin-right:10px;"/><a href="${topicComment.fileUrls[fileName_index]}" target='_blank'>${fileName}</a></div>
	      	  </#list>
	      	  </div>
	      	  </#if>
	          <div class="jieda-reply">
	            <span class="jieda-zan zanok <#if topic.finish>finish</#if>" type="zan" id="up_${topicComment.id!''}" <#if topic.finish>title="已结贴"</#if>>
	            	<#if topic.finish == false>
	            		<#include "/apps/topic/up.html">
	            	<#else>
	            		<i class="iconfont icon-zan"></i><em>${topicComment.up!0}</em>
	            	</#if>
	            </span>
	            <!-- <span type="reply"><i class="iconfont icon-svgmoban53"></i>回复</span>  -->
	            <#if user?? && ( (user.usertype?? && user.usertype == "0") || user.id == topic.creater ) && topic.finish == false>
	            <div class="jieda-admin">
	            	<#if user.usertype?? && user.usertype == "0">
	              	<a href="/jsluntan/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html" onclick="layer.confirm('请确认是否删除评论？' , {icon: 3, title:'操作提示'},function(){location.href = '/jsluntan/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html'} ,  function(index){layer.close(index);});return false;"><span type="del">删除</span></a>
	              	</#if>
	              	<#if topicComment.optimal>
		              	<a href="/jsluntan/topic/unoptimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
		              	<span class="jieda-accept" type="accept">取消采纳</span>
		              	</a>
	              	<#else>
		              	<a href="/jsluntan/topic/optimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
		              	<span class="jieda-accept" type="accept">采纳</span>
		              	</a>
	              	</#if>
	            </div>
	            </#if>
	          </div>
	        </li>
	        </#list>
	        <#else>
	        <li class="fly-none">没有任何回答</li>
	        </#if>
	        
	      </ul>
	      
	      <div id="pages">
	      
	      </div>
	      <div class="layui-form layui-form-pane">
	      	<#if topic.finish == false>
		      	<#if user??>
		        <form action="/jsluntan/topic/comment/${topic.id!''}.html" method="post">
		        	<div class="layui-form-item layui-form-text">
		            	<div class="layui-input-block">
		              		<textarea id="content" name="content" placeholder="我要回答"  class="layui-textarea fly-editor" style="height: 150px;"></textarea>
		            	</div>
		          	</div>
		          
	      			<div class="layui-form-item" style="display:none;">
	        			<label for="L_title" class="layui-form-label">附件名称</label>
	        			<div class="layui-input-block">
	          				<input type="text" id="L_filename" name="filename" autocomplete="off" class="layui-input">
	        			</div>
	      			</div>
	      			<div class="layui-form-item" style="display:none;">
	        			<label for="L_title" class="layui-form-label">附件链接</label>
	        			<div class="layui-input-block">
	         				<input type="text" id="L_fileurl" name="fileurl" autocomplete="off" class="layui-input">
	        			</div>
	      			</div>
	      
		          	<div class="layui-form-item">
						<input type="file" name="file" lay-type="file" class="layui-upload-file">
						<span id="files"></span>
			      	</div>
		          	<div class="layui-form-item">
		            	<input type="hidden" name="dataid" value="${topic.id!''}">
		            	<button class="layui-btn" lay-filter="*" lay-submit>提交回答</button>
		          	</div>
		        </form>
		        <#else>
		        	<div style="text-align:center;margin-top:30px;">
			        	<a href="https://www.gainseng.com/f/account/login.html" style="color: #32c24d;font-weight:bold;">登录</a>
			        	<!-- 或 -->
			        	<!-- <a href="/jsluntan/login.html" style="color: #32c24d;font-weight:bold;">注册</a> -->
			        	后提交回答
		        	</div>
		        </#if>
	        <#else>
	      		<div style="text-align:center;margin-top:30px;">
			                              已结贴
		        </div>
	      	</#if>
	      </div>
	      
	    </div>
	  </div>
	  <div class="edge">
	  	<#if user?? && user.usertype?? && user.usertype == "0">
	  	<h3 class="page-title">管理功能</h3>
	    <ol class="manage-list">
	      <li>
	      	<span>
	      		<#if topic.essence>
	      			<a href="/jsluntan/topic/unessence/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe631;</i>
		        		取消精华
		        	</a>
	        	<#else>
		        	<a href="/jsluntan/topic/essence/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe631;</i>
		        		精华
		        	</a>
	        	</#if>
	        </span>
	        <span>
	        	<#if topic.top>
	      			<a href="/jsluntan/topic/untop/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe631;</i>
		        		取消置顶
		        	</a>
	        	<#else>
		        	<a href="/jsluntan/topic/top/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe631;</i>
		        		置顶
		        	</a>
	        	</#if>
	        	
	        </span>
	        <span>
	        	<a href="javascript:void(0)" style="color:red;" onclick="layer.confirm('请确认是否删除主题？' , {icon: 3, title:'操作提示'},function(){location.href = '/jsluntan/topic/delete/${topic.id!''}.html'} ,  function(index){layer.close(index);});return false;">
	        		<i class="layui-icon">&#x1006;</i>
	        		删除
	        	</a>
	        </span>
	        <#if !topic.finish>
		        <span>
		        	<a href="/jsluntan/topic/finish/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe618;</i>
		        		结贴
		        	</a>
		        </span>
		    <#else>
		    	<span>
		        	<a href="/jsluntan/topic/unfinish/${topic.id!''}.html">
		        		<i class="layui-icon">&#xe618;</i>
		        		取消结贴
		        	</a>
		        </span>
	        </#if>
	      </li>
	      
	    </ol>
	    </#if>
	  	
	    <h3 class="page-title">最近热帖</h3>
	    <ol class="fly-list-one">
	    	<#if relaAnswersList??>
	    	<#list relaAnswersList.content as relaViewsTopic>
		      <li>
		        <a href="/jsluntan/topic/detail/${relaViewsTopic.id!''}.html">${relaViewsTopic.title!''}</a>
		        
		        <div class="ukefu-ask-rela">
		        	<span title="发表时间"><i class="iconfont">&#xe60b;</i> ${relaViewsTopic.updatetime?string('yyyy-MM-dd HH:mm:ss')}</span>
		        	<span title="回复数"><i class="iconfont"></i> ${relaViewsTopic.answers!0}</span>
		        	<span title="关注数"><i class="iconfont">&#xe60b;</i> ${relaViewsTopic.views!0}</span>
		        </div>
		      </li>
		    </#list>
		    </#if>
	    </ol>
	    
	    <h3 class="page-title">近期热议</h3>
	    <ol class="fly-list-one">
	    	<#if relaViewsList??>
	    	<#list relaViewsList.content as relaAnswerTopic>
		      <li>
		        <a href="/jsluntan/topic/detail/${relaAnswerTopic.id!''}.html">${relaAnswerTopic.title!''}</a>
		        
		        <div class="ukefu-ask-rela">
		        	<span title="发表时间"><i class="iconfont">&#xe60b;</i> ${relaAnswerTopic.updatetime?string('yyyy-MM-dd HH:mm:ss')}</span>
		        	<span title="回复数"><i class="iconfont"></i> ${relaAnswerTopic.answers!0}</span>
		        	<span title="关注数"><i class="iconfont">&#xe60b;</i> ${relaAnswerTopic.views!0}</span>
		        </div>
		      </li>
		    </#list>
		    </#if>
	    </ol>
	    
	  </div>
  </div>
  <script>
    var layedit,index; 
  	layui.use(['laypage', 'layer'], function(){
  		var laypage = layui.laypage;
	  	laypage({
		    cont: 'pages'
		    ,first:'首页'
		    ,last:'末页'
		    ,pages: ${topicCommentList.totalPages}
		    ,curr:${topicCommentList.number+1}
		    ,skin: '#32c24d'
		    ,jump:function(obj, first){
		    	var curr = obj.curr;
		    	if(!first){
		    		location.href = '/jsluntan/topic/detail/${topic.id!""}.html?p='+curr;
		    	}
		    }
		});
	});
  	layui.use('layedit', function(){
  	  layedit = layui.layedit;
	  layedit.set({
	  	  uploadImage: {
	  	    url: '/jsluntan/topic/upload.html' //接口url
	  	    ,type: 'post' //默认post
	  	  }
  	  }); 
  	  index = layedit.build('content'); //建立编辑器
  	});
  	
	layui.use('upload', function(){
  		layui.upload({
  			url: '/jsluntan/topic/upload.html',
  			before:function(res){
  				console.log("before res : " + res.value);
  			},
  			success: function(res){
  		    	console.log("success res : " + res.data.src); //上传成功返回值，必须为json格式
  		    	var b = document.getElementById("files");
  		    	b.innerHTML = b.innerHTML + "<a style='margin-left:15px;' href='"+res.data.path+"' target='_blank'> " + res.data.title + "</a>";
  		    	
  		    	var fname = document.getElementById("L_filename");
  		    	if(fname.value == null || fname.value == "") {
  		    		fname.value = res.data.title;
  		    	} else {
  		    		fname.value = fname.value + "," + res.data.title;
  		    	}

  		    	var furl = document.getElementById("L_fileurl");
  		    	if(furl.value == null || furl.value == "") {
  		    		furl.value = res.data.path;
  		    	} else {
  		    		furl.value = furl.value + "," + res.data.path;
  		    	}
  		  	}
  		});
  	});

  </script>